<?php

namespace app\common\model;

use think\facade\Request;
use think\Model;
use think\model\concern\SoftDelete;

class Admin extends Model
{
    //

    use SoftDelete;
    public function login($data){
        $result = $this->where($data)->find();
        if($result){
            $session = [
                'id'       => $result['id'],
                'nickname' => $result['nickname'],
                'is_super' => $result['is_super']
            ];
            session('admin', $session);
            return 1;
        }else{
            return 0;
        }
    }
    public static function getList($where = array(), $pageSize, $order = ['sort', 'id' => 'desc'])
    {
        $list = self::where($where)
            ->order($order)
            ->paginate($pageSize, false, ['query' => Request::get()]);
        return $list;
    }
}
